﻿/*******************************************************
*类名称：WechatLogManager
*版本号：V1.0.0.0
*作者：成俊杰
*CLR版本：4.0.30319.36264
*创建时间：2017-08-16 22:47:50
*说明：T_WechatLog管理类
*更新备注：
**********************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wechat.Dao;
using Wechat.Domain;
using Wechat.Util.ParmsConfig;

namespace Wechat.Manager.Implement
{
    /// <summary>
    /// T_WechatLog
    /// </summary>
    public class WechatLogManager : GenericManagerBase<WechatLog>, IWechatLogManager
    {
        /// <summary>
        /// 判断用户是否在一定时间内发送过信息
        /// </summary>
        /// <returns>发送过则为false</returns>
        public bool HasMsgLogByOpenId(string fromUser)
        {
            var result = true;
            string condition = @"SELECT TOP 1 * FROM T_WechatLog WHERE FromUserName=@FromUserName AND 
 GETDATE() < DATEADD(MINUTE,5,CreateTime) 
 Order By Id DESC";
            var wechatLog = LoadByCondition(condition, new { FromUserName = fromUser }).FirstOrDefault();
            if (wechatLog != null)
            {
                result = false;
            }
            return result;
        }
    }
}